package yancy.modules.sys.entity;


import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import yancy.common.validator.group.AddGroup;
import yancy.common.validator.group.UpdateGroup;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Date;

@Data
@TableName("sys_borrow_book")
public class SysBorrowBook {
    @TableId
    @NotNull(message = "borrowId不能为空")
    private Long borrowId;
    @NotNull(message = "bookId不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private Long bookId;
    @NotNull(message = "userId不能为空", groups = {AddGroup.class})
    private Long userId;
    @NotNull(message = "total不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private Long total;
    private Long needBack;
    private Long status;
    private Long createUserId;
    private Date createTime;
    @NotNull(message = "还书时间不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private Date limitTime;

    @TableField(exist = false)
    private SysBook book;
    @TableField(exist = false)
    private String typeStatus;


    public void returnBook(Long returnCount) {
        needBack -= returnCount;
    }
}
